package org.feng.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 枚举字段实体
 *
 * @version V1.0
 * @author: fengjinsong
 * @date: 2022年09月06日 19时55分
 */
@Data
public class EnumEntity implements Serializable {
    private String enumName;
    private String code;
    private String hanYuName;

    @Override
    public String toString() {
        return enumName + "(\"" + code + "\", \"" + hanYuName + "\")";
    }

    public static List<String> toEnum(List<EnumEntity> enumEntities) {
        List<String> resultList = new ArrayList<>(enumEntities.size() * 2);
        for (int i = 0; i < enumEntities.size(); i++) {
            resultList.add("/** " + enumEntities.get(i).getCode() + "：" + enumEntities.get(i).getHanYuName() +" */");
            if (i != enumEntities.size() - 1) {
                resultList.add(enumEntities.get(i).toString() + ",");
            } else {
                resultList.add(enumEntities.get(i).toString() + ";");
            }
        }
        return resultList;
    }
}
